﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading;

namespace FizzBuzz
{
    class StaticThreadDemo : ISynchronizeInvoke
    {
        // each thread get its own copy of the following static variable
        // each thread has to initiaize the variable as static constructor has no effect 
        // on thread relative statics
        [ThreadStatic]
        static string name;

        public int Add(int a, int b)
        {
            return a + b;
        }

        public IAsyncResult BeginInvoke(Delegate method, object[] args)
        {
            throw new NotImplementedException();
        }

        public object EndInvoke(IAsyncResult result)
        {
            throw new NotImplementedException();
        }

        public object Invoke(Delegate method, object[] args)
        {
            throw new NotImplementedException();
        }

        public bool InvokeRequired
        {
            get { throw new NotImplementedException(); }
        }

        public void ShowThreadLocalStorage()
        {
            LocalDataStoreSlot dataStorage = Thread.AllocateNamedDataSlot("My TLS Slot");
        }

        public void ShowThreadPoolAvailableThreads()
        {
            int workerThreads, completionPortThreads;
            ThreadPool.GetMaxThreads(out workerThreads, out completionPortThreads);
            Console.WriteLine("Max - Worker Threads:{0}, Completion Port Threads:{1}", workerThreads, completionPortThreads);

            ThreadPool.GetMinThreads(out workerThreads, out completionPortThreads);
            Console.WriteLine("Min - Worker Threads:{0}, Completion Port Threads:{1}", workerThreads, completionPortThreads);

            ThreadPool.SetMinThreads(100, 100);

            ThreadPool.GetMinThreads(out workerThreads, out completionPortThreads);
            Console.WriteLine("Min - Worker Threads:{0}, Completion Port Threads:{1}", workerThreads, completionPortThreads);
        }


    }
}
